<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | ProjectName: php
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.xfjpeter.cn
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 201907292019-07-29
 * | ---------------------------------------------------------------------------------------------------
 * | Desc:
 * | ---------------------------------------------------------------------------------------------------
 */

namespace app\admin\controller;

class Attachment extends Base
{
    /**
     * 上传文件
     */
    public function upload()
    {
        $file = $this->request->file('file');
        if ($file) {
            $info = $file->move(config('johnxu.upload_path'));

            $this->ok(200, ['url' => config('johnxu.upload_path') . $info->getSaveName()]);
        } else {
            $this->fail(200, 1, $file->getError());
        }
    }
}